(function(window, undefined){
  'use strict';
  var ns = window.beneath = window.beneath || {};

  function Pregame() {
  }

  Pregame.prototype = {
    init : function (state) {
      this.state = state[0];
    },

    create: function () {
      var text = this.add.bitmapText(0,0,'font', 'Day ' + this.state.day, 48);

      text.x = this.world.centerX - text.textWidth / 2;
      text.y = this.world.height + 10;

      var tween = this.add.tween(text)
        .to({y : this.world.centerY - 10}, 500, Phaser.Easing.Quadratic.InOut)
        .to({y : this.world.centerY - 10}, 250, Phaser.Easing.Quadratic.InOut)
        .to({y : this.world.height}, 500, Phaser.Easing.Quadratic.InOut)
        .start();

      var self = this;
      setTimeout(function () {
        self.gotoGame();
      }, 1400);
    },

    gotoGame : function gotoGameFn(){
      this.game.state.start('game', true, false, [this.state]);
    }
  };

  window.beneath.Pregame = Pregame;

})(window);